#include <iostream>
#include <algorithm>
#include <ctime>
#include <cstring>
#include <cstdlib>
#include <cstdio>

using namespace std;

int& recursiveMinimum (int *array, int start, int end)
{
    static int *min = NULL;
    if (min == NULL) min = &array[start];
    if (start == end) 
    {
        int *rt = min;
        min = NULL;
        return *rt;
    }
    if (array[start] < *min) min = array + start;
    return recursiveMinimum (array, start + 1, end);
}

int main()
{
    const int SIZE = 10;
    srand ((unsigned)time(NULL));
    int array[SIZE];
    generate_n (array, SIZE, rand);
    
    for (int i = 0; i < SIZE; ++i)
        cout << array[i] << " ";
    cout << endl;

    cout << endl << recursiveMinimum (array, 0, SIZE - 1) << endl;
    cout << endl << recursiveMinimum (array, SIZE - 2, SIZE - 1) << endl;

    return 0;
}

